/************************************\
|* unittest4.c                      *|
|* By Danny Burrows                 *|
|* burrowsd@onid.oregonstate.edu    *|
|* CS362 - Spring 2014              *|
|*                                  *|
|* Assignment 3                     *|
|*                                  *|
|* Simple unit tests of the         *|
|* shuffle function inside of       *|
|* dominion.c                       *|
\************************************/

#include <stdio.h>
#include <stdlib.h>
#include "dominion.h"

void runTests(struct gameState *game)
{
	/* int playCard(int handPos, int choice1, int choice2, int choice3, struct gameState *state) */
	//int handPos = (rand() % 6) + 1;
	struct gameState *gameAfter = malloc(sizeof(struct gameState));
	int handSize;

	for (int i = 0; i < 10; i++)
	{
		handSize = (rand() % 10) + 5; // between 5 and 15 cards
		for (int j = 0; j < handSize; ++j)
		{
			game->deck[0][j] = rand() % 27; // set a random card to the deck
			game->deckCount[0]++;
		}
		memcpy(gameAfter, game, sizeof(struct gameState)); // make a copy to compare against
	
		shuffle(0, game);
		printf("Size of hand - %d\t", handSize);
		if (memcmp(game, gameAfter, sizeof(struct gameState)) == 0) { // they are equal
			printf("FAIL, same order of cards.\n");
		} else {
			printf("PASS, cards are in a different order.\n");
		}
	
	}
	free(gameAfter);
	return;
}

int main(int argc, char const *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	runTests(game);

	free(game);

	return 0;
}